package com.dell.chen.service.Impl;

import com.dell.chen.dao.UserDao;
import com.dell.chen.dao.impl.UserDaoImpl;
import com.dell.chen.pojo.Users;
import com.dell.chen.service.UserService;

/**
 * @author ：ChenwithIU
 * @date ：Created in 2020/11/24 19:14
 */
public class UserServiceImpl implements UserService {
    private UserDao userDao = new UserDaoImpl();
    @Override
    public Users login(Users users) {
        return userDao.queryUserByUsernameAndPassword(users.getUsername(),users.getPassword());
    }

    @Override
    public void register(Users users) {
        userDao.saveUser(users);
    }

    @Override
    public boolean existUsername(String username) {
        if (userDao.queryUserByUsername(username) == null){
            return false;//没有查询到相同用户名
        }
        return true;
    }

    @Override
    public void update(Users users) {
        userDao.updateUser(users);
    }
}
